import {
  Controller,
  Get,
  Post,
  Put,
  Delete,
  Body,
  Param,
  Query,
  UseGuards,
  UseInterceptors,
  UploadedFile,
  UploadedFiles,
  Session,
  Req,
} from '@nestjs/common';
import { FileInterceptor, FilesInterceptor } from '@nestjs/platform-express';
import {
  ApiTags,
  ApiOperation,
  ApiResponse,
  ApiConsumes,
} from '@nestjs/swagger';
import { Request } from 'express';
import { JwtAuthGuard } from '@wwjCommon/security/guards/jwt-auth.guard';
import { RolesGuard } from '@wwjCommon/security/guards/roles.guard';
import { Roles } from '@wwjCommon/security/decorators/roles.decorator';
import { Public } from '@wwjCommon/security/decorators/public.decorator';
import { BusinessException } from '@wwjCommon/exception/business.exception';
// @UploadedFile() - 单文件上传，配合 @UseInterceptors(FileInterceptor('file'))
// @UploadedFiles() - 多文件上传，配合 @UseInterceptors(FilesInterceptor('files'))
// @Session() - 获取会话对象，对应PHP Session::get()
// @Req() - 获取Request对象，对应PHP Request
import { WeappDeliveryService } from '../../services/admin/weapp-delivery.service';

/**
 * DeliveryController
 * 对应 PHP: Delivery Controller
 * 对应 Java: @RestController
 *
 * 支持装饰器：
 * - @UploadedFile() - 单文件上传 (对应PHP Request::file())
 * - @UploadedFiles() - 多文件上传
 * - @Session() - 会话管理 (对应PHP Session::get())
 * - @Req() - 请求对象 (对应PHP Request)
 */
@ApiTags('weapp')
@Controller('adminapi/weapp')
export class DeliveryController {
  constructor(private readonly weappDeliveryService: WeappDeliveryService) {}

  /**
   * 小程序发货信息管理服务
   * 路由: GET delivery/getIsTradeManaged
   * PHP路由: Route::get('delivery/getIsTradeManaged', 'weapp.Delivery/getIsTradeManaged')
   */
  @Get('delivery/getIsTradeManaged')
  @UseGuards(JwtAuthGuard, RolesGuard)
  @ApiOperation({ summary: '小程序发货信息管理服务' })
  async getIsTradeManaged(): Promise<ApiResponse> {
    try {
      // 基于PHP真实逻辑实现
      // PHP原始方法: getIsTradeManaged

      return await this.weappDeliveryService.getIsTradeManaged();
    } catch (error) {
      throw new BusinessException('getIsTradeManaged操作失败', error);
    }
  }
}
